/**
 * @param {number[]} spells
 * @param {number[]} potions
 * @param {number} success
 * @return {number[]}
 */
var successfulPairs = function(spells, potions, success) {
  // spells = spells.sort((a, b) => a - b);
  potions = potions.sort((a, b) => a - b);
  let result = [];
  for(let i = 0; i < spells.length; i++) {
    let count = 0;
    for(let j = 0; j < potions.length; j++) {
      if(spells[i] * potions[j] >= success) {
        count += potions.length - j;
        break;
      }
    }
    result.push(count);
  }
  return result;
};
let spells = [5,1,3], potions = [1,2,3,4,5], success = 7;
console.log(successfulPairs(spells, potions, success));
spells = [3,1,2], potions = [8,5,8], success = 16;
console.log(successfulPairs(spells, potions, success));
